{extend name="../public/header" /}
{block name="body"}
<body>
{include file="../public/top" uname="$roleInfo.uname" lv="$roleInfo.ulv" ls="$roleInfo.uyxb" jp="$roleInfo.uczb" /}
<div class="subject main">
    <div class="layui-row">
        <div class="content">
            <div class="current">
                <span class="position">{$roleInfo.map.mname}</span>
                <span class="state">{if $roleInfo.map.ispvp==0}[安全区]{else/}[PVP]{/if}</span>
                <span class="info ajax-goto" data-url="{:url('index')}">返回</span>
            </div>
            <div class="refine">
                <div class="market">
                    <div class="layui-tab">
                        <ul class="layui-tab-title">
                            <li class="layui-this">架子</li>
                            <li>我的</li>
                        </ul>
                        <div class="layui-tab-content">
                            <div class="layui-tab-item layui-show">
                                <div class="layui-col-md12" style="margin-bottom: 10px">
                                    <div class="layui-card">
                                        <div class="layui-card-header">筛选</div>
                                        <div class="layui-card-body" style="font-size: 12px;">
                                            <form class="layui-form"  action="{:url('prop')}" method="post">
                                                <div class="layui-form-item">
                                                    <input type="text" name="djname" value="{$pageMaps.djname|default=''}" placeholder="请输入名称" autocomplete="off" class="layui-input">
                                                </div>
                                                <div class="layui-form-item">
                                                    <button lay-submit lay-filter="search" class="layui-btn layui-btn-primary layui-btn-xs">查找</button>
                                                </div>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                                <table class="layui-table" lay-size="sm">
                                    <thead>
                                    <tr>
                                        <th>名称</th>
                                        <th>数量</th>
                                        <th>灵石</th>
                                        <th width="30">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {if(count($list)<1)}
                                    <tr>
                                        <td colspan="4" align="center">暂无相关数据</td>
                                    </tr>
                                    {else /}
                                    {volist name='$list' id='vo' key='k'}
                                    <tr>
                                        <td>{$vo.djname}</td>
                                        <td>{$vo.djcount}</td>
                                        <td>{$vo.pay}</td>
                                        <td>
                                            <a class="layui-btn layui-btn-xs ajax-act" data-value='{$vo.str}' data-type="buy">购</a>
                                        </td>
                                    </tr>
                                    {/volist}
                                    {/if}
                                    </tbody>
                                </table>
                                <div class="layui-col-md12">
                                    <div class="layui-card">
                                        <div class="layui-card-body" style="font-size: 12px;">
                                            {$_page|raw}
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-tab-item">
                                <table class="layui-table" lay-size="sm">
                                    <thead>
                                    <tr>
                                        <th>名称</th>
                                        <th>数量</th>
                                        <th>灵石</th>
                                        <th width="30">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {if(count($listMy)<1)}
                                    <tr>
                                        <td colspan="4" align="center">暂无相关数据</td>
                                    </tr>
                                    {else /}
                                    {volist name='$listMy' id='vo' key='k'}
                                    <tr>
                                        <td>{$vo.djname}</td>
                                        <td>{$vo.djcount}</td>
                                        <td>{$vo.pay}</td>
                                        <td>
                                            <a class="layui-btn layui-btn-xs ajax-act" data-value='{$vo.str}' data-type="back">下</a>
                                        </td>
                                    </tr>
                                    {/volist}
                                    {/if}
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
{/block}
{block name="script"}
<script>
    layui.use(['jquery', 'form', 'layajax', 'upload', 'flow', 'element'], function () {
        var $ = layui.jquery
            , layajax = layui.layajax
            , upload = layui.upload
            , element = layui.element
            , flow = layui.flow
            , form = layui.form;

        $('.ajax-act').on('click', function () {
            var obj = $(this);
            var str = obj.data('value');
            var type = obj.data('type');

            var url = '{:url("propAct")}';
            console.log('url', url);

            var map = {};
            map['str'] = str;
            map['act'] = type;

            $.post(url, map, function (res) {
                if (res.code == undefined) {
                    console.log('res为json字符串', res);
                    res = JSON.parse(res);
                } else {
                    console.log('res为json对象', res);
                }
                if (res.code == 1) {
                    layer.msg(res.msg,{time:1000}, function(index){
                        location.reload();
                    });
                } else {
                    layer.msg(res.msg);
                }
            });
        });

        form.render();
    });
</script>
{/block}